﻿using System;

/*
 * A dictionary is stored as a sequence of text lines containing words and their explanations.
 * Write a program that enters a word and translates it by using the dictionary.
 */

namespace Dictionary
{
    class Dictionary
    {
        static string FoundWord(string[] dictionary, string word)
        {
            string foundSentence = "";
            foreach (string sentence in dictionary)
            {
                if (sentence.StartsWith(word, StringComparison.CurrentCultureIgnoreCase))
                {
                    foundSentence = sentence;
                }
            }

            int startIndex = foundSentence.IndexOf('-') + 1;
            return startIndex > 0 ? foundSentence.Substring(startIndex) : "Nothing found!";
        }

        static void Main()
        {
            string[] dictionary = {
                ".NET - platform for applications from Microsoft",
                "CLR - managed execution environment for .NET",
                "namespace - hierarchical organization of classes"
            };
            string word = ".NET";

            Console.WriteLine("Word: {0}", word);
            Console.WriteLine("Explanation: {0}", FoundWord(dictionary, word).Trim());
        }
    }
}
